import { METHODS } from 'http'
import { url } from 'inspector'
const mockList = [
  {
    id: 1,
    name: '废水排放总量',
    unit: '万吨',
    data: '',
    attribute: '预期性指标',
    vant: '',
  },
  {
    id: 2,
    name: '环境空气质量达标率',
    unit: '%',
    data: '',
    attribute: '约束指标',
    vant: '',
  },
  {
    id: 3,
    name: '万元GDP电耗',
    unit: '万元/千瓦时',
    data: '',
    attribute: '约束指标',
    vant: '',
  },
  {
    id: 4,
    name: '规模以上废弃资源综合利用业总产值',
    unit: '亿元',
    data: '',
    attribute: '预期性指标',
    vant: '',
  },
  {
    id: 5,
    name: '森林覆盖率',
    unit: '%',
    data: '',
    attribute: '预期性指标',
    vant: '',
  },
  {
    id: 6,
    name: '生态环境状况指数',
    unit: 'EI指数',
    data: '',
    attribute: '预期性指标',
    vant: '',
  },
  {
    id: 7,
    name: '商品进出口总值',
    unit: '亿元',
    data: '',
    attribute: '预期性指标',
    vant: '',
  },
  {
    id: 8,
    name: '外商投资企业数',
    unit: '个',
    data: '',
    attribute: '预期性指标',
    vant: '',
  },
]
export default [
  {
    url: '/api/carbon/label',
    method: 'get',
    response: () => {
      return {
        code: 200,
        data: [
          {
            id: 1,
            name: '废水排放总量',
            unit: '万吨',
            data: '',
            attribute: '预期性指标',
            vant: '',
          },
          {
            id: 2,
            name: '环境空气质量达标率',
            unit: '%',
            data: '',
            attribute: '约束指标',
            vant: '',
          },
          {
            id: 3,
            name: '万元GDP电耗',
            unit: '万元/千瓦时',
            data: '',
            attribute: '约束指标',
            vant: '',
          },
          {
            id: 4,
            name: '规模以上废弃资源综合利用业总产值',
            unit: '亿元',
            data: '',
            attribute: '预期性指标',
            vant: '',
          },
          {
            id: 5,
            name: '森林覆盖率',
            unit: '%',
            data: '',
            attribute: '预期性指标',
            vant: '',
          },
          {
            id: 6,
            name: '生态环境状况指数',
            unit: 'EI指数',
            data: '',
            attribute: '预期性指标',
            vant: '',
          },
        ],
      }
    },
  },
  // 删除
  {
    url: '/api/carbon/label/delete',
    method: 'delete',
    response: ({ body }) => {
      const { id } = body
      const index = mockList.findIndex((item) => {
        return item.id === id
      })
      mockList.splice(index, 1)
      console.log(123)

      console.log(mockList)

      return {
        code: 200,
        message: '碳标签数据删除成功',
        data: {
          content: mockList,
        },
      }
    },
  },
  {
    url: '/api/carbon/label/edit',
    method: 'put',
    response: ({ body }) => {
      console.log('我在这里')

      const { id } = body
      console.log(11)

      console.log(id)

      const targetResource = mockList.find((resource) => resource.id === id)
      if (targetResource) {
        Object.assign(targetResource, body)
        return {
          code: 200,
          message: '编辑成功',
          data: targetResource,
        }
      }
      return {
        code: 200,
        message: '编辑成功',
        data: targetResource,
      }
    },
  },
]
